﻿#ifndef PST_MARKERINTERACTIONSTYLE_H
#define PST_MARKERINTERACTIONSTYLE_H

#include <vtkInteractorStyleRubberBandPick.h>
#include <vtkDataSetMapper.h>
#include <vtkIdTypeArray.h>

#include <vtkSmartPointer.h>
#include <vtkPointData.h>
#include <vtkIdTypeArray.h>
#include <vtkDataSetSurfaceFilter.h>
#include <vtkRendererCollection.h>
#include <vtkProperty.h>
#include <vtkPlanes.h>
#include <vtkObjectFactory.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkPointSource.h>
#include <vtkInteractorStyleRubberBandPick.h>
#include <vtkAreaPicker.h>
#include <vtkExtractGeometry.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
#include <vtkVertexGlyphFilter.h>
#include <vtkIdFilter.h>

class vtkActor;
class vtkProperty;
class vtkDataSet;
class vtkCamera;
class vtkAxesActor;
class vtkIdTypeArray;
class vtkAreaPicker;
class vtkRenderWindow;
class vtkRenderer;
class vtkCoordinate;
class vtkSphereSource;
class vtkAngleRepresentation3D;
class vtkDistanceRepresentation3D;
class vtkPoints;
class vtkInteractorStyleTrackballCamera;
class vtkNamedColors;
class vtkPointPicker;
class vtkCellPicker;
class vtkDistanceToCamera;
class vtkExtractCells;
class vtkFeatureEdges;

namespace pst
{
    class PostMarkerInteractionStyle;
    class Graph3DWindowBase;
    class PostMarkerInteractionStyle : public vtkInteractorStyleTrackballCamera
    {
    public:
        static PostMarkerInteractionStyle* New();
        vtkTypeMacro(PostMarkerInteractionStyle, vtkInteractorStyleTrackballCamera);

    public:
        // void setPostWindow(PostWindowBase* win);
        //  type 0 :Point ， 1：Cell
        void setPickerType(int type);
        int getPickerType() const;

        void setMoveSphereRadius(int radius);

        void setEnablePicking(bool on);

        void setRender(vtkRenderer* render);

        void setParentWindow(Graph3DWindowBase* win);

        // 0 左键按住是旋转，1 左键按住是平移
        void setInnerInteractionStyle(int style);
        int getInnerInteractionStyle() const;

    protected:
        virtual void OnLeftButtonDown() override;
        virtual void OnLeftButtonUp() override;
        virtual void OnRightButtonDown() override;
        virtual void OnMouseMove() override;
        virtual void OnKeyPress() override;
        //virtual void Rotate() override;


    protected:
        PostMarkerInteractionStyle();
        ~PostMarkerInteractionStyle();

    private:
        void generateFixedSizeBall();
        void initCellPickerPipeLine();
    private:
        Graph3DWindowBase* m_graph3DWindowBase;

        // 捕捉球
        vtkSmartPointer<vtkPolyDataMapper> m_moveMapper;
        vtkSmartPointer<vtkActor> m_moveActor;

        // 捕捉cell
        vtkSmartPointer<vtkIdList> idList;
        vtkSmartPointer<vtkExtractCells> extractCells;
        vtkSmartPointer<vtkGeometryFilter> geometryFilter;
        vtkSmartPointer<vtkFeatureEdges> featureEdges;
        vtkSmartPointer<vtkDataSetMapper> edgeMapper;
        vtkSmartPointer<vtkActor> edgeActor;


        vtkSmartPointer<vtkCellPicker> m_pointPicker;
        vtkSmartPointer<vtkCellPicker> m_cellPicker;
        vtkSmartPointer<vtkNamedColors> m_namedColor;
        vtkSmartPointer<vtkDistanceToCamera> m_distanceToCamera;
        bool m_isEnablePicking;
        int m_pickerType;
        int m_interactionStyle; //0 左键按住是旋转 1 左键按住是旋转
    };
} // namespace pst

#endif
